<template>
  <footer class="footer">
    <!-- 在 template 中访问所有数据都不需要加 this, 可加可不加 -->
    <span class="todo-count">剩余<strong>{{ this.list.length }}</strong></span>
    <ul @click="changeSel(isSel)" class="filters">
      <li>
        <!-- @click 绑定事件时, 如果只执行一行代码, 可以直接写在后面, 如果要用到 data 中的变量, 不需要加 this, 事件处理函数中不能加 this -->
        <!-- 为了记忆方便, 只要在 template 中用到数据, 都不加 this -->
        <a @click="changeAll()" :class="{ selected: isSel === 'all' }" href="javascript:;" >全部</a>
      </li>
      <li>
        <a @click="changeNo()" :class="{ selected: isSel === 'no' }"  href="javascript:;">未完成</a>
      </li>
      <li>
        <a @click="changeYes()" :class="{ selected: isSel === 'yes' }"  href="javascript:;" >已完成</a>
      </li>
    </ul>
    <button @click="clearDone()" class="clear-completed" >清除已完成</button>
  </footer>
</template>

<script>

import { mapState , mapMutations} from 'vuex'
export default {
 
  computed:{
     ...mapState('TodoMain',['list']),
     ...mapState('TodoMain',['isSel']),
     
  },
  data() {
    return {
      
    }
  },
  methods: {
    ...mapMutations('TodoMain',['changeSel']),
    ...mapMutations('TodoMain',['changeAll']),
    ...mapMutations('TodoMain',['changeNo']),
    ...mapMutations('TodoMain',['changeYes']),
    ...mapMutations('TodoMain',['clearDone']),

  }
}
</script>